<?php
// +----------------------------------------------------------------------
// | ZGUAN [ 致力于帮助更多的中小企业物联网转型 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.zguan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ZGUAN 并不是自由软件，未经许可不能去掉ZGUAN 相关版权
// +----------------------------------------------------------------------
// | Author: ZGUAN Team <admin@zguan.cn>  0769-82282996  15899929162
// +----------------------------------------------------------------------
namespace app\common\repositories\housing;

use app\common\repositories\BaseRepository;
use app\common\dao\housing\HousingPictureDao;

/**
 * Class HousingPictureRepository
 *
 * @mixin HousingPictureDao
 */
class HousingPictureRepository extends BaseRepository
{

    public function __construct(HousingPictureDao $dao)
    {
        $this->dao = $dao;
    }


    public function addPicture(int $housingId, array $data, int $isType = 1, $remark = null)
    {
        $insertData = [];
        foreach ($data as $k => $v) {
            if ($v) {
                $insertData[] = [
                    'housing_id' => $housingId,
                    'remark' => $remark,
                    'is_type' => $isType,
                    'image_url' => $v,
                ];
            }
        }
        return $this->dao->insertAll($insertData);
    }
}